<template>
    
    <!-- 组件的模板 -->
    <div class="page wx-invite">
        <div class="bg"></div>
        <div class="layer-wrap" v-bind:class="{'active':isshow}">
            <div class="wrap">
                <div class="layer">
                    <div class="semi-circle"></div>
                    <img class="avatar" v-if="inviteData.logo.thumb_url" :src="inviteData.logo.thumb_url" alt="">
                    <img class="avatar" v-else src="http://sta.doumistatic.com/src/image/saas/avatar.png" alt="">
                    <div class="top" :class="{'top_haveteam': haveTeam ,'top_noteam': !haveTeam}">
                        <div style="height: 52px"></div>
                        <p class="tip">邀请你加入项目</p>
                        <div class="text">
                            <h2>{{inviteData.project_name}}</h2>
                            <p class="team" v-if="inviteData.project_name != inviteData.group_name">{{inviteData.group_name}}</p>
                        </div>
                    </div>
                    <!-- <div class="placeholder_top"></div> -->
                    <div class="content">
                        <div class="form-wrap">
                            <div class="realname_tip" v-if="is_name_auth == 1">
                                <img src="../../static/imgs/realname_tip.png" class="realname_img">
                                <span class="realname_text">项目开启实名认证，请填写你的真实信息</span>
                            </div>
                            <form>
                                <div class="weui-cells weui-cells_form">
                                    <div class="weui-cell">
                                        <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
                                        <div class="weui-cell__bd">
                                            <input class="weui-input" type="text" placeholder="请输入" :value="user_name" v-model="user_name" :disabled="hasReal_name" :class="{'isdisabled':(hasReal_name && andriodStyle)}">
                                        </div>
                                    </div>
                                    <div class="weui-cell">
                                        <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
                                        <div class="weui-cell__bd">

                                            <input class="weui-input" type="tel" placeholder="请输入" :value="phone" v-model="phone" :disabled="hasPhone" :class="{'isdisabled':(hasPhone && andriodStyle)}"> 
                                        </div>
                                    </div>

                                    <template v-for="item in items">
                                        <a class="weui-cell weui-cell_access" href="javascript:;" id="sexPicker" @click="sexPicker_timer" v-if="item.id == 1">
                                            <div class="weui-cell__hd"><label class="weui-label">性别</label></div>
                                            <div class="weui-cell__bd">
                                                <span v-if=" sexData != '' && sexData !== undefined" :class="{'isdisabled':(hasReal_name && sexData)}">{{sexData}}</span>
                                                <span class="placeholder" v-else style="color:rgb(187,187,187)">请选择</span>
                                            </div>
                                            <div class="weui-cell__ft" v-if="!(hasReal_name && sexData)"></div>
                                        </a>
                                        <div class="weui-cell" v-if="item.id == 2">
                                            <div class="weui-cell__hd"><label class="weui-label">身高(cm)</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="tel" placeholder="请输入" :value="user_height" v-model="user_height">
                                            </div>
                                        </div>
                                        <div class="weui-cell" v-if="item.id == 3">
                                            <div class="weui-cell__hd"><label class="weui-label">体重(kg)</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="tel" placeholder="请输入" :value="user_weight" v-model="user_weight">
                                            </div>
                                        </div>
                                        <div class="weui-cell" v-if="item.id == 4">
                                            <div class="weui-cell__hd"><label class="weui-label">学校</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="text" placeholder="请输入" :value="user_school" v-model="user_school">
                                            </div>
                                        </div>
                                        <a class="weui-cell weui-cell_access" href="javascript:;" id="datePicker" @click="datePicker_timer" v-if="item.id == 5">
                                            <div class="weui-cell__hd"><label class="weui-label">出生年月</label></div>
                                            <div class="weui-cell__bd">
                                                <span v-if="birthDate != '' && birthDate !== undefined" v-bind:class="{'isdisabled':(hasReal_name && birthDate)}">{{birthDate}}</span>
                                                <span class="placeholder" v-else style="color:rgb(187,187,187)">请选择</span>
                                            </div>
                                            <div class="weui-cell__ft" v-if="!(hasReal_name && birthDate)"></div>
                                        </a>
                                        <div class="weui-cell" v-if="item.id == 6">
                                            <div class="weui-cell__hd"><label class="weui-label">身份证号</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="text" placeholder="请输入" :value="user_identity" v-model="user_identity" :disabled="hasReal_name" :class="{'isdisabled':(hasReal_name && andriodStyle)}">
                                            </div>
                                        </div>
                                        <a class="weui-cell weui-cell_access" href="javascript:;" id="placePicker" @click="placePicker_timer" v-if="item.id == 7">
                                            <div class="weui-cell__hd"><label class="weui-label">居住地点</label></div>
                                            <div class="weui-cell__bd">
                                                <span v-if = "placeResult != ' ' && placeResult !== undefined && placeResult !== ''">{{placeResult}}</span>
                                                <span class="placeholder" v-else style="color:rgb(187,187,187)">请选择</span>
                                            </div>
                                            <div class="weui-cell__ft"></div>
                                        </a>
                                        <div class="weui-cell" v-if="item.id == 8">
                                            <div class="weui-cell__hd"><label class="weui-label">人员编号</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="text" placeholder="请输入" :value="personnel_number" v-model="personnel_number">
                                            </div>
                                        </div>
                                        <div class="weui-cell" v-if="item.id == 9">
                                            <div class="weui-cell__hd"><label class="weui-label">详细地址</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="text" placeholder="请输入" :value="datail_address" v-model="datail_address">
                                            </div>
                                        </div>                                       
                                        <a class="weui-cell weui-cell_access" href="javascript:;" id="datePicker" @click="datePicker_timer_graduation" v-if="item.id == 10">
                                            <div class="weui-cell__hd"><label class="weui-label">毕业时间</label></div>
                                            <div class="weui-cell__bd">
                                                <span v-if="graduate_date != '' && graduate_date !== undefined">{{graduate_date}}</span>
                                                <span class="placeholder" v-else style="color:rgb(187,187,187)">请选择</span>
                                            </div>
                                            <div class="weui-cell__ft"></div>
                                        </a>
                                        <a class="weui-cell weui-cell_access" href="javascript:;" id="datePicker" @click="datePicker_timer_entry" v-if="item.id == 11">
                                            <div class="weui-cell__hd"><label class="weui-label">入职日期</label></div>
                                            <div class="weui-cell__bd">
                                                <span v-if="entry_date != '' && entry_date !== undefined">{{entry_date}}</span>
                                                <span class="placeholder" v-else style="color:rgb(187,187,187)">请选择</span>
                                            </div>
                                            <div class="weui-cell__ft"></div>
                                        </a>
                                        <a class="weui-cell weui-cell_access" href="javascript:;" id="degreePicker" @click="degreePicker_timer" v-if="item.id == 12">
                                            <div class="weui-cell__hd"><label class="weui-label">学历</label></div>
                                            <div class="weui-cell__bd">
                                                <span v-if=" degree != '' && degree !== undefined">{{degree}}</span>
                                                <span class="placeholder" v-else style="color:rgb(187,187,187)">请选择</span>
                                            </div>
                                            <div class="weui-cell__ft"></div>
                                        </a>
                                        <div class="weui-cell" v-if="item.id == 13">
                                            <div class="weui-cell__hd"><label class="weui-label">专业</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="text" placeholder="请输入" :value="specialty" v-model="specialty">
                                            </div>
                                        </div> 
                                        <div class="weui-cell" v-if="item.id == 14">
                                            <div class="weui-cell__hd"><label class="weui-label">开户人</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="text" placeholder="开户人姓名" :value="bank" v-model="bank">
                                            </div>
                                        </div>
                                        <div class="weui-cell" v-if="item.id == 15">
                                            <div class="weui-cell__hd"><label class="weui-label">开户行</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="text" placeholder="开户行全称" :value="bank_info" v-model="bank_info">
                                            </div>
                                        </div> 
                                        <div class="weui-cell" v-if="item.id == 16">
                                            <div class="weui-cell__hd"><label class="weui-label">银行卡号</label></div>
                                            <div class="weui-cell__bd">
                                                <input class="weui-input" type="tel" placeholder="请输入" :value="bank_card_number" v-model="bank_card_number">
                                            </div>
                                        </div> 
                                    </template>
                                    <div class="weui-cell last-cell"></div>
                                </div>
                                <a class="btn-join" href="javascript:;" @click="addProject">加入项目</a>
                            </form>
                        </div>
                    </div>
                    <!-- <div class="btn_box">
                        <a class="btn-join btn-join-position" :class="{'btn-index':btnIndex}" href="javascript:;" @click="addProject">加入项目</a>
                        <div class="color_place_left"></div>
                        <div class="color_place_right"></div>
                        <div class="color_place_bottom"></div>
                    </div> -->
                </div>
                <!-- 二维码的显示 -->
                <div class="layer qrcode-wrap">
                    <div class="top">
                        <div class="text">
                            <h2>长按识别二维码加入项目</h2>                    
                        </div>
                    </div>
                    <div class="content">
                        <div class="box">
                            <!-- 线上二维码 -->
                            <img class="qrcode" src="../../static/imgs/qrcode.jpg" alt="">
                            <!-- 测试二维码 -->
                            <!-- <img class="qrcode" src="../../static/imgs/qrcode_for_test.jpg" alt=""> -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
       <!--  <p class="download"><a href="javascript:;">下载灵云</a></p> -->
    </div>
   <!--  <div class="mod-toast"><p>错误提示，请重新尝试！</p></div>  -->   
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import widget from 'gapi/widget.js'
    import * as util from 'js/util.js'
    import cache from 'gapi/cache.js'
    import clientInfo from 'gapi/clientInfo.js'
    import KCApiApp from 'clientApi/KCApiApp.js'
    import commonPage from 'clientApi/commonPage.js'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                inviteData: {
                    logo: {
                        url: "",
                        thumb_url: ""
                    }
                },
                // isAdd: false,
                user_name: '',
                // user_name_init: false,
                phone: '',
                // phone_init: false,
                user_height: '',
                user_weight: '',
                user_identity: '',
                user_school: '',
                isshow: false,
                isRight: false,
                birthDate: '',//出生日期
                sexData: '' ,//性別
                sexId: '',//性别value
                placeResult: '', //居住地点
                items: [],
                province_id: '',
                province_name: '',                
                city_id: '',
                city_name: '',
                district_id: '',
                district_name: '',
                btnIndex: true,
                pickerYear: '',
                pickerMonth: '',
                dataDate: [],
                yearDate:{
                    label: '',
                    value: 0,
                    children: []
                },
                monthDate: {
                    label: '',
                    value: 1
                },
                personnel_number: 0,//人员编号
                datail_address: '',//详细地址
                graduate_date: '',//毕业时间
                graduate_date_year: '',//毕业时间
                graduate_date_mounth: '',//毕业时间
                entry_date: '',//入职日期
                entry_date_year: '',//入职年份
                entry_date_mounth: '',//入职月份
                entry_date_day: '',//入职日
                degree: '',//学历
                specialty: '',//专业
                bank: '',//银行卡开户名
                bank_info: '',//开户行全称
                bank_card_number: 0,//银行卡号
                degreeId: 1,//学历ID
                hasPhone: false,//手机号是否可修改
                hasReal_name: false,//是否实名认证
                protocolData: '',//电子协议返回数据
                urlBeforejump: '',
                haveTeam: true,//是否有小组名称
                andriodStyle: true,
                is_name_auth: 0,//是否开启实名认证
            }
        },
        computed: {
            teamId: function(){
                return util.getUrddataString("teamId");
            },
            projectId: function(){
                return util.getUrddataString("projectId");
            },
            // projectName: function(){
            //     return util.getUrddataString("projectName");
            // },
            getCode: function(){
                return util.getUrddataString("code");
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
               init (){
                    //ios和安卓样式不兼容
                    if(util.OS() =='ios'){
                        this.andriodStyle = false
                    }else{
                        this.andriodStyle = true
                    }
                    this.initAjax();
                    //获取跳转前缀
                    clientInfo.getHost((host) => {
                        host = host.info;
                        this.urlBeforejump = host
                    })
                 
                // let j = 1
                //     while(j < 13){
                //         this.monthDate.label = j + "月"
                //         this.yearDate.children.push({
                //             label: this.monthDate["label"],
                //             value: ''
                //         })
                //         j++
                //     }
                // let date = new Date()
                // let i = 1940
                // while (i <= date.getFullYear()){
                //     this.yearDate.label = i + "年"
                //     this.dataDate.push({
                //         label:this.yearDate["label"],
                //         value:'',
                //         children:this.yearDate["children"]
                //     })
                //     i++;
                // }      
            },

            initAjax(){
                
                // alert(this.getCode)
                const that = this
                util.ajax({
                    type: 'GET',
                    url:  '/group/invite_wechat',
                    data: {
                        // group_id: this.groupId,
                        // project_id: this.projectId,
                        // user_id: this.userId,
                        // team_id: this. teamId
                        code: this.getCode
                    },
                    success: (res) => {
                        this.getPosition();//保证初始数据都请求完成再获取地区数据！
                        if(res.errno == 0){
                            that.inviteData = res.data;
                            that.items = that.inviteData.required_field_info;
                            that.is_name_auth = res.data.is_name_auth
                            if(that.inviteData.project_name != that.inviteData.group_name){
                                that.haveTeam = true
                            }else{
                                that.haveTeam = false
                            }
                            console.log('必须填写的数据',JSON.stringify(res.data))
                            if(that.inviteData.current_user_info.real_name_auth == 1){
                                that.hasReal_name = true
                            }else{
                                that.hasReal_name = false
                            }
                            if(that.inviteData.current_user_info.real_name){
                                that.user_name = that.inviteData.current_user_info.real_name;
                            }else{
                                this.user_name = '';
                            }
                            if(that.inviteData.current_user_info.mobile){
                                that.phone = that.inviteData.current_user_info.mobile;
                                that.hasPhone = true
                            }else{
                                this.phone = '';
                            }
                            that.items.forEach((obj) =>{
                                if(obj.id == 1){
                                    if(obj.value == 1){
                                        this.sexData = '男'
                                    }else if(obj.value == 2){
                                        this.sexData = '女'
                                    }else{
                                        this.sexData = ''
                                    } 
                                    this.sexId = obj.value 
                                    
                                }else if(obj.id == 2){
                                    // this.user_height = obj.value
                                    if(obj.value == 0){
                                        this.user_height = ''
                                    }else{
                                        this.user_height = obj.value
                                    }
                                }else if(obj.id == 3){
                                    // this.user_weight = obj.value
                                    if(obj.value == 0){
                                        this.user_weight = ''
                                    }else{
                                        this.user_weight = obj.value
                                    }
                                }else if(obj.id == 4){
                                    this.user_school = obj.value                                    
                                }else if(obj.id == 5){                                               
                                    if(obj.value!='' && obj.value!= 0){
                                        this.birthDate = obj.value.replace(/-/g,'年') + '月'
                                    }else if(obj.value == 0){
                                        this.birthDate = ''
                                    }else{
                                        this.birthDate = obj.value 
                                    }
                                }else if(obj.id == 6){
                                    this.user_identity = obj.value                                    
                                }else if(obj.id == 7){
                                    // this.placeResult = obj.value
                                    this.province_id = obj.value.province_id
                                    this.city_id = obj.value.city_id
                                    this.district_id = obj.value.district_id
                                }else if(obj.id == 8){
                                    this.personnel_number = obj.value                        
                                }else if(obj.id == 9){
                                    this.datail_address = obj.value                        
                                }else if(obj.id == 10){
                                    if(obj.value!='' && obj.value!= 0){
                                        this.graduate_date = obj.value.replace(/-/g,'年') + '月'
                                        this.graduate_date_year = this.graduate_date.substring(0,4)
                                        
                                        // if(this.birthDate.substr(5,1) == '0'){
                                        //     this.pickerMonth = this.birthDate.slice(6,-1)
                                        // }else{
                                            this.graduate_date_mounth = this.graduate_date.slice(5,-1)
                                        // }                                       
                                        
                                    }else if(obj.value == 0){
                                        this.graduate_date = ''
                                    }else{
                                        this.graduate_date = obj.value 
                                    }                       
                                }else if(obj.id == 11){
                                    if(obj.value!='' && obj.value!= 0){
                                        this.entry_date = obj.value
                                        this.entry_date = this.entry_date.replace(/-/,'年')
                                        this.entry_date = this.entry_date.replace(/-/,'月') + '日'
                                        this.entry_date_year = this.entry_date.substring(0,4)                      
                                        this.entry_date_mounth = this.entry_date.substring(5,7)
                                        this.entry_date_day = this.entry_date.substring(8,10)                      
                                        
                                    }else if(obj.value == 0 || obj.value == ''){
                                        let defaultEntry_year = new Date().getFullYear()
                                        let defaultEntry_mounth = new Date().getMonth()+1
                                        let defaultEntry_day = new Date().getDate()
                                        this.entry_date = defaultEntry_year +'年'+ defaultEntry_mounth +'月'+ defaultEntry_day +'日'
                                    }else{
                                        this.entry_date = obj.value 
                                    }                         
                                }else if(obj.id == 12){
                                    if(obj.value == 1){
                                        this.degree = '初中及以下'
                                    }else if(obj.value == 2){
                                        this.degree = '高中'
                                    }else if(obj.value == 3){
                                        this.degree = '大专'
                                    }else if(obj.value == 4){
                                        this.degree = '本科'
                                    }else if(obj.value == 5){
                                        this.degree = '硕士'
                                    }else if(obj.value == 6){
                                        this.degree = '博士及以上'
                                    }else{
                                        this.degree = ''
                                    } 
                                    this.degreeId = obj.value                     
                                }else if(obj.id == 13){
                                    this.specialty = obj.value                        
                                }else if(obj.id == 14){
                                    this.bank = obj.value                        
                                }else if(obj.id == 15){
                                    this.bank_info = obj.value                        
                                }else if(obj.id == 16){
                                    if(obj.value == 0){
                                        this.bank_card_number = ''
                                    }else{
                                        this.bank_card_number = obj.value
                                    }                                                            
                                }
                            })
                        }else{
                            widget.toast(res.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        var toastStr = ''
                        if(status == 'timeout'){
                            toastStr = '网络请求超时'
                        }else{
                            toastStr = '网络连接失败，请检查网络'
                        }

                        widget.toast(toastStr)
                    },
                    complete: () => {

                    },
                    noNetwork: () => {
                        // 无网络的回调
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            //获取地区数据
            getPosition(){
                util.ajax({                    
                    url: '/common/geography/get',
                    type:'GET',
                    data:{
                        team_id:0,
                        project_id:0
                    },
                    beforeSend: () => {

                    },
                    success: (obj) => {
                        if(obj.errno == 0){


                            this.placeData = obj.data
                            this.placeData.forEach((obj1) => {  

                                if(this.province_id == obj1.province_id){
                                    this.province_name = obj1.short_name
                                }
                                obj1.label = obj1.short_name
                                delete obj1.short_name
                                obj1.value = obj1.province_id
                                delete obj1.province_id
                                obj1.children = obj1.child
                                delete obj1.child
                                obj1.children.forEach((obj2) => {

                                    if(this.city_id == obj2.city_id){
                                        this.city_name = obj2.short_name
                                    }
                                    obj2.label = obj2.short_name
                                    delete obj2.short_name
                                    obj2.value = obj2.city_id
                                    delete obj2.city_id
                                    obj2.children = obj2.child
                                    delete obj2.child
                                    obj2.children.forEach((obj3) => {

                                        if(this.district_id == obj3.district_id){
                                            this.district_name = obj3.short_name
                                        }
                                        obj3.label = obj3.short_name
                                        delete obj3.short_name
                                        obj3.value = obj3.district_id
                                        delete obj3.district_id
                                    })
                                })
                            })
                            if(this.province_name == this.city_name){
                                this.placeResult = this.province_name + ' ' + this.district_name
                            }else{
                                this.placeResult = this.province_name + ' ' + this.city_name + ' ' + this.district_name
                            }
                            console.log(666999,this.placeResult)
                            console.log(1,this.province_name)
                            console.log(2,this.city_name)
                            console.log(3,this.district_name)
                        }else{
                            widget.toast(obj.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        var toastStr = ''
                        if(status == 'timeout'){
                            toastStr = '网络请求超时'
                        }else{
                            toastStr = '网络连接失败，请检查网络'
                        }

                        widget.toast(toastStr)
                    },
                    complete: () => {

                    },
                    noNetwork: () => {
                        // 无网络的回调
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            //校验身份证号
            identityCodeValid(code){
                let city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
                let tip = "";
                let pass= true;
                if(!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)){
                    tip = "身份证号格式错误";
                    pass = false;
                }
                else if(!city[code.substr(0,2)]){
                    tip = "地址编码错误";
                    pass = false;
                }
                else{
                    //18位身份证需要验证最后一位校验位
                    if(code.length == 18){
                        code = code.split('');
                        if(code[17] === 'x')code[17]='X'
                        //∑(ai×Wi)(mod 11)
                        //加权因子
                        let factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
                        //校验位
                        let parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
                        let sum = 0;
                        let ai = 0;
                        let wi = 0;
                        for (let i = 0; i < 17; i++)
                        {
                            ai = code[i];
                            wi = factor[i];
                            sum += ai * wi;
                        }
                        let last = parity[sum % 11];
                        if(parity[sum % 11] != code[17]){
                            tip = "校验位错误";
                            pass =false;
                        }
                    }
                }
                // if(!pass) alert(tip);
                return pass;
            },
            //点击加入项目
            addProject(){
                
                //验证姓名是否含有特殊字符
                let reg = /[^\u4E00-\u9FA5\·]/;
                if(!this.user_name){
                  widget.toast("请输入真实姓名");
                  return
                }else if( reg.test(this.user_name)){
                   widget.toast("请输入真实姓名，否则无法加入项目");
                  return
                }

                //校验手机号和用户名是否完善
                if(!this.phone){
                    widget.toast("请完善信息");
                    return
                }
                //校验手机号
                if(this.phone){
                    if(!(/^\d{11}$/.test(this.phone))){ 
                        widget.toast('手机号格式错误')
                        return
                    }
                    else{
                        this.isRight = true
                    }
                }else{
                    widget.toast("请完善信息");
                    return
                }
                var student = new Object();
                var addData = new Array();
                student.user_name = this.user_name; 
                student.identity = "999999"; 
                student.phone = this.phone;
                for(let i = 0; i<this.items.length; i++){
                // this.items.forEach((obj) => {
                    if(this.items[i].id == 1){
                        if(this.sexData){
                            student.gender = this.sexId
                        }else{
                            widget.toast("请选择性别");
                            return
                        }
                    }else if(this.items[i].id == 2){
                        if(this.user_height && this.user_height != 0){
                            student.height = this.user_height
                        }else{
                            widget.toast("请填写身高");
                            return
                        }
                    }else if(this.items[i].id == 3){
                        if(this.user_weight && this.user_weight != 0){
                            student.weight = this.user_weight
                        }else{
                            widget.toast("请填写体重");
                            return
                        }
                    }else if(this.items[i].id == 5){
                        if(this.birthDate){
                            let changeDate = this.birthDate.replace(/年/g,'-')
                            changeDate = changeDate.replace(/月/g,'')
                            student.birthday = changeDate
                        }else{
                            widget.toast("请选择出生年月");
                            return
                        }
                    }else if(this.items[i].id == 6){
                        if(this.user_identity){
                            // if(!this.identityCodeValid(this.user_identity)){
                            //     widget.toast('身份证号格式错误')
                            //     return
                            // }else{
                                student.idnumber = this.user_identity
                            // }
                        }else{
                            widget.toast("请填写身份证号");
                            return
                        }
                    }else if(this.items[i].id == 7){
                        if(this.placeResult != ' ' && this.placeResult != undefined && this.placeResult != ''){
                            // student.address = this.placeResult
                            student.province_id = this.province_id
                            student.city_id = this.city_id
                            student.district_id = this.district_id
                        }else{
                            //toast
                            widget.toast("请填写居住地址");
                            return
                        }
                    }else if(this.items[i].id == 4){
                        if(this.user_school){
                            student.school = this.user_school
                        }
                    }else if(this.items[i].id == 8){
                        if(this.personnel_number && this.personnel_number != 0){
                            student.personnel_number = this.personnel_number
                        }else{
                            widget.toast("请填写人员编号");
                            return
                        }
                    }else if(this.items[i].id == 9){
                        if(this.datail_address && this.datail_address != ''){
                            student.datail_address = this.datail_address
                        }else{
                            widget.toast("请填写详细地址");
                            return
                        }
                    }else if(this.items[i].id == 10){
                        if(this.graduate_date && this.graduate_date != 0){
                            // student.graduate_date = this.graduate_date
                            let graduateDate = this.graduate_date.replace(/年/g,'-')
                            graduateDate = graduateDate.replace(/月/g,'')
                            student.graduate_date = graduateDate
                        }else{
                            widget.toast("请填写毕业时间");
                            return
                        }
                    }else if(this.items[i].id == 11){
                        if(this.entry_date && this.entry_date != 0){
                            // student.entry_date = this.entry_date                            
                            let entryDate = this.entry_date.replace(/年/g,'-')
                            entryDate = entryDate.replace(/月/g,'-')
                            entryDate = entryDate.replace(/日/g,'')
                            student.entry_date = entryDate
                            // alert(student.entry_date)
                        }else{
                            widget.toast("请填写入职日期");
                            return
                        }
                    }else if(this.items[i].id == 12){
                        if(this.degree){
                            student.degree = this.degreeId
                        }else{
                            widget.toast("请填写学历");
                            return
                        }
                    }else if(this.items[i].id == 13){
                        if(this.specialty && this.specialty != ''){
                            student.specialty = this.specialty
                        }else{
                            widget.toast("请填写专业");
                            return
                        }
                    }else if(this.items[i].id == 14){
                        if(this.bank && this.bank != 0){
                            student.bank = this.bank
                        }else{
                            widget.toast("请填写银行开户名");
                            return
                        }
                    }else if(this.items[i].id == 15){
                        if(this.bank_info && this.bank_info != ''){
                            student.bank_info = this.bank_info
                        }else{
                            widget.toast("请填写开户行全称");
                            return
                        }
                    }else if(this.items[i].id == 16){
                        if(this.bank_card_number && this.bank_card_number != 0){
                            student.bank_card_number = this.bank_card_number
                        }else{
                            widget.toast("请填写银行卡号");
                            return
                        }
                    }
                }
                commonPage.loadPageStatus('loading')
                // student.group_id = this.groupId;
                addData.push(student);
                var jsonData = JSON.stringify(addData)
                let params = new Object();
                params.user_list = jsonData
                params.code = this.getCode
                params.source = "1"
                params.dmclient = "weixinqy"
                params = JSON.stringify(params)
                const _this = this
                console.log('传入',params)
                util.ajax({
                    type: 'POST',
                    url: '/protocol/check',
                    data: { 
                            "url": 'sea/api/1.0/client/v1/group/member_add_share',
                            "params": params
                    },
                    success: (res) => { 
                        commonPage.loadPageStatus('loadSuccess')
                        console.log("点击加入项目"+JSON.stringify(res))                   
                    
                        if(res.errno == 0 &&　this.isRight == true){
                            if(res.data.jump_data){

                                //成功即跳转到电子协议页      
                                this.protocol_user_id = res.data.jump_data.protocol_user_id
                                this.protocol_order_id = res.data.jump_data.protocol_order_id
                                window.location.href = this.urlBeforejump +'/sea/api/1.0/client/v1/protocol/jumpSignPage?dmclient=weixinqy&' +  'protocol_user_id=' + this.protocol_user_id + '&protocol_order_id=' + this.protocol_order_id
                            }else{                                
                                //成功即跳转到项目详情页
                                let str = `team_id=${this.teamId}&project_name=${encodeURIComponent(this.inviteData.project_name)}&project_id=${this.projectId}`
                                window.location.href=`dmsaas://ProjectDetail?${str}` 
                            }
                        }
                        else{
                            widget.toast(res.errmsg)
                        }
                    },
                    error: (xhr, status) => {
                        commonPage.loadPageStatus('loadSuccess')
                        var toastStr = ''
                        if(status == 'timeout'){
                            toastStr = '网络请求超时'
                        }else{
                            toastStr = '网络连接失败，请检查网络'
                        }

                        widget.toast(toastStr)
                    },
                    complete: () => {

                    },
                    noNetwork: () => {
                        commonPage.loadPageStatus('loadSuccess')
                        // 无网络的回调
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            //日期选择器(年月日)------出生年月
            datePicker_timer(){
                if(this.hasReal_name && this.birthDate){
                    return
                }else{                    
                    setTimeout(this.datePicker,400);
                    this.btnIndex = false
                }
            },
            datePicker(){
                weui.datePicker({
                    start: 1940,
                    end: new Date(),
                    defaultValue: [this.pickerYear, this.pickerMonth, 9],
                    className: 'custom-classname',
                    onChange: (result) => {
                        console.log("666"+result);
                        
                    },
                    onConfirm: (result) => {
                        this.pickerYear = result[0].label.slice(0,-1)
                        this.pickerMonth = result[1].label.slice(0,-1)
                        if(result[1].label == '10月' || result[1].label == '11月' || result[1].label == '12月'){                            
                            this.birthDate = result[0].label + result[1].label                          
                        }else{
                            this.birthDate = result[0].label + '0' + result[1].label
                        }
                        this.btnIndex = true
                        console.log('1313',typeof result[1].label)
                        console.log('2424',this.birthDate)
                         
                    },
                    id: 'datePicker'
                });
            },
            //日期选择器(年月日)------毕业时间
            datePicker_timer_graduation(){
                setTimeout(this.datePicker_graduation,400);
                this.btnIndex = false
            },
            datePicker_graduation(){
                weui.datePicker({
                    start: 1940,
                    end: new Date(),
                    defaultValue: [this.graduate_date_year, this.graduate_date_mounth, 9],

                    className: 'custom-classname',

                    onChange: (result) => {
                        console.log("666"+result);
                        
                    },
                    onConfirm: (result) => {
                        console.log(result)
                        this.graduate_date_year = result[0].label.slice(0,-1)
                        this.graduate_date_mounth = result[1].label.slice(0,-1)                       
                        // this.graduate_date = result[0].label + result[1].label 

                        if(result[1].label == '10月' || result[1].label == '11月' || result[1].label == '12月'){                            
                            this.graduate_date = result[0].label + result[1].label                          
                        }else{
                            this.graduate_date = result[0].label + '0' + result[1].label
                        }


                        this.btnIndex = true
                         
                    },
                    id: 'datePicker'
                });
            },
            //日期选择器(年月日)------入职日期
            datePicker_timer_entry(){
                setTimeout(this.datePicker_entry,400);
                this.btnIndex = false
            },
            datePicker_entry(){
                let defaultEntry_year,
                    defaultEntry_mounth,
                    defaultEntry_day;
                defaultEntry_year = this.entry_date_year ? this.entry_date_year : new Date().getFullYear()
                defaultEntry_mounth = this.entry_date_mounth ? this.entry_date_mounth : new Date().getMonth()+1
                defaultEntry_day = this.entry_date_day ? this.entry_date_day : new Date().getDate()
                let default_date = defaultEntry_year+'-'+defaultEntry_mounth+'-'+defaultEntry_day
                KCApiApp.showDatePicker("2015-01-01",  "2019-01-01", default_date, (data) => {
                    this.entry_date = data.SelectedDate
                    this.entry_date = this.entry_date.replace(/-/,'年')
                    this.entry_date = this.entry_date.replace(/-/,'月') + '日'
                    this.btnIndex = true
                }, )
            },


            //性別选择器

            sexPicker_timer(){
                if(this.hasReal_name && this.sexData){
                   return
               }else{                    
                   setTimeout(this.sexPicker,400);
                   this.btnIndex = false
               }
            },

            sexPicker(){
                weui.picker([
                {
                    label: '男',
                    value: 1,
                    // disabled: true // 不可用
                },
                {
                    label: '女',
                    value: 2
                }
                ], {

                   className: 'custom-classname',

                   defaultValue: [this.sexId],
                   onChange: (result) => {
                       // console.log(result)
                   },
                   onConfirm: (result) => {
                       // console.log(result)
                       this.sexData = result[0].label
                       if(result[0].label == '男'){
                            this.sexId = 1
                       }else if(result[0].label == '女'){
                            this.sexId = 2
                       }else{
                            this.sexId = 0
                       }
                       this.btnIndex = true
                       // console.log('選擇的性別')
                       // console.log(this.sexData)
                   },
                   id: 'sexPicker'
                });
            },

            //居住地點选择器

            placePicker_timer(){
                setTimeout(this.placePicker,400)
                this.btnIndex = false
            },

            placePicker(){
                // 级联picker
                let _this = this
                weui.picker(_this.placeData, {
                   className: 'custom-classname',
                   defaultValue: [this.province_id, this.city_id,this.district_id],
                   onChange: (result) => {
                       // console.log(result)
                   },
                   onConfirm: (result) => {
                        console.log('我是地点结果')
                        if(result[0].label == result[1].label){
                            this.placeResult = result[0].label + ' ' + result[2].label
                        }else{
                            this.placeResult = result[0].label + ' ' + result[1].label + ' ' + result[2].label
                        }
                        this.province_id = result[0].value
                        this.city_id = result[1].value
                        this.district_id = result[2].value
                        this.btnIndex = true
                        console.log(this.province_id,this.city_id,this.district_id)
                        
                   },
                   id: 'placePicker'
                });
            },
            //学历选择器
            degreePicker_timer(){
                setTimeout(this.degreePicker,400);
                this.btnIndex = false
            },
            degreePicker(){
                weui.picker([
                {
                    label: '初中及以下',
                    value: 1,
                    // disabled: true // 不可用
                },
                {
                    label: '高中',
                    value: 2
                },
                {
                    label: '大专',
                    value: 3
                },
                {
                    label: '本科',
                    value: 4
                },
                {
                    label: '硕士',
                    value: 5
                },
                {
                    label: '博士及以上',
                    value: 6
                },
                ], {
                   className: 'custom-classname',
                   defaultValue: [this.degreeId],
                   onChange: (result) => {
                       // console.log(result)
                   },
                   onConfirm: (result) => {
                       console.log("我是学历结果"+result[0].label)
                       this.degree = result[0].label
                       this.degreeId = result[0].value
                       // if(result[0].label == '男'){
                       //      this.sexId = 1
                       // }else if(result[0].label == '女'){
                       //      this.sexId = 2
                       // }else{
                       //      this.sexId = 0
                       // }
                       this.btnIndex = true
                       // console.log('選擇的性別')
                       // console.log(this.sexData)
                   },
                   id: 'degreePicker'
                });
            }
        },
        created(){

            this.init();
            
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/wx-invite.css"></style>
<style>
    .toast_bottom_father{
        width: 100%;
        text-align: center;
    }
    .wx-invite .layer .content {
        background: #fff;
        position: relative;
    }
    .weui-cells:after {
      display: none;
    }
    .weui-cell_access:active {
      background-color: #ffffff;
    }
    .placeholder_logo{
        height: 100px;
        width: 100px;
    }
    .wx-invite .btn-join {
        display: block;
        height: 44px;
        line-height: 44px;
        /* border-radius: 22px; */
        /* background: linear-gradient(to bottom right, rgb(255, 204, 106), rgb(255, 168, 86), rgb(255, 149, 88)); */
        background: rgb(250,170,0);
        text-align: center;
        font-size: 16px;
        color: rgb(255,255,255);
        /*text-shadow: 0 1px 2px rgba(229, 123, 0, 0.85);*/
        /*box-shadow: 0 3px 9px 1px rgba(255, 159, 0, 0.45);*/
        /*width: 88%;*/
        border-radius: 2px;
    }
    .realname_tip{
        width: 100%;
        height: 48px;
        text-align: center;
        line-height: 56px;
        font-size: 12px;
        color: #999999;
        letter-spacing: 0;
    }
    .realname_img{
        width: 16px;
        height: 16px;
        margin-right: 4px;
        position: relative;
        top: 3px;
    }
</style>

